<html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - rand_kernel_abstract.h</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2003  Davis E. King (davis@dlib.net)
</font><font color='#009900'>// License: Boost Software License   See LICENSE.txt for the full license.
</font><font color='#0000FF'>#undef</font> DLIB_RAND_KERNEl_ABSTRACT_
<font color='#0000FF'>#ifdef</font> DLIB_RAND_KERNEl_ABSTRACT_

<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>string<font color='#5555FF'>&gt;</font>
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../uintn.h.html'>../uintn.h</a>"

<font color='#0000FF'>namespace</font> dlib
<b>{</b>


    <font color='#0000FF'>class</font> <b><a name='rand'></a>rand</b>
    <b>{</b>

        <font color='#009900'>/*!      
            INITIAL VALUE
                get_seed() == ""


            WHAT THIS OBJECT REPRESENTS
                This object represents a pseudorandom number generator.
        !*/</font>
        
        <font color='#0000FF'>public</font>:


            <b><a name='rand'></a>rand</b><font face='Lucida Console'>(</font>
            <font face='Lucida Console'>)</font>;
            <font color='#009900'>/*!
                ensures 
                    - #*this is properly initialized
                throws
                    - std::bad_alloc
            !*/</font>

            <b><a name='rand'></a>rand</b> <font face='Lucida Console'>(</font>
                time_t seed_value
            <font face='Lucida Console'>)</font>;
            <font color='#009900'>/*!
                ensures 
                    - #*this is properly initialized
                    - #get_seed() == cast_to_string(seed_value) 
                    - This version of the constructor is equivalent to using
                      the default constructor and then calling set_seed(cast_to_string(seed_value))
                throws
                    - std::bad_alloc
            !*/</font>

            <b><a name='rand'></a>rand</b> <font face='Lucida Console'>(</font>
                <font color='#0000FF'>const</font> std::string<font color='#5555FF'>&amp;</font> seed_value
            <font face='Lucida Console'>)</font>;
            <font color='#009900'>/*!
                ensures 
                    - #*this is properly initialized
                    - #get_seed() == seed_value
                    - This version of the constructor is equivalent to using
                      the default constructor and then calling set_seed(seed_value)
                throws
                    - std::bad_alloc
            !*/</font>

            <font color='#0000FF'>virtual</font> ~<b><a name='rand'></a>rand</b><font face='Lucida Console'>(</font>
            <font face='Lucida Console'>)</font>; 
            <font color='#009900'>/*!
                ensures
                    - all memory associated with *this has been released
            !*/</font>

            <font color='#0000FF'><u>void</u></font> <b><a name='clear'></a>clear</b><font face='Lucida Console'>(</font>
            <font face='Lucida Console'>)</font>;
            <font color='#009900'>/*!
                ensures
                    - #*this has its initial value
                throws
                    - std::bad_alloc
                        if this exception is thrown then *this is unusable 
                        until clear() is called and succeeds
            !*/</font>

            <font color='#0000FF'>const</font> std::string<font color='#5555FF'>&amp;</font> <b><a name='get_seed'></a>get_seed</b> <font face='Lucida Console'>(</font>
            <font face='Lucida Console'>)</font>;
            <font color='#009900'>/*!
                ensures
                    - returns the string currently being used as the random seed.
            !*/</font>

            <font color='#0000FF'><u>void</u></font> <b><a name='set_seed'></a>set_seed</b> <font face='Lucida Console'>(</font>
                <font color='#0000FF'>const</font> std::string<font color='#5555FF'>&amp;</font> value
            <font face='Lucida Console'>)</font>;
            <font color='#009900'>/*!
                ensures
                    - #get_seed() == value
            !*/</font>

            <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>char</u></font> <b><a name='get_random_8bit_number'></a>get_random_8bit_number</b> <font face='Lucida Console'>(</font>
            <font face='Lucida Console'>)</font>;
            <font color='#009900'>/*!
                ensures
                    - returns a pseudorandom number in the range 0 to 255
            !*/</font>

            uint16 <b><a name='get_random_16bit_number'></a>get_random_16bit_number</b> <font face='Lucida Console'>(</font>
            <font face='Lucida Console'>)</font>;
            <font color='#009900'>/*!
                ensures
                    - returns a pseudorandom number in the range 0 to 2^16-1 
            !*/</font>

            uint32 <b><a name='get_random_32bit_number'></a>get_random_32bit_number</b> <font face='Lucida Console'>(</font>
            <font face='Lucida Console'>)</font>;
            <font color='#009900'>/*!
                ensures
                    - returns a pseudorandom number in the range 0 to 2^32-1 
            !*/</font>

            uint64 <b><a name='get_random_64bit_number'></a>get_random_64bit_number</b> <font face='Lucida Console'>(</font>
            <font face='Lucida Console'>)</font>;
            <font color='#009900'>/*!
                ensures
                    - returns a pseudorandom number in the range 0 to 2^64-1 
            !*/</font>

            <font color='#0000FF'><u>float</u></font> <b><a name='get_random_float'></a>get_random_float</b> <font face='Lucida Console'>(</font>
            <font face='Lucida Console'>)</font>;
            <font color='#009900'>/*!
                ensures
                    - returns a random float number N where:  0.0 &lt;= N &lt; 1.0.
            !*/</font>

            <font color='#0000FF'><u>double</u></font> <b><a name='get_random_double'></a>get_random_double</b> <font face='Lucida Console'>(</font>
            <font face='Lucida Console'>)</font>;
            <font color='#009900'>/*!
                ensures
                    - returns a random double number N where:  0.0 &lt;= N &lt; 1.0.
            !*/</font>

            <font color='#0000FF'><u>double</u></font> <b><a name='get_double_in_range'></a>get_double_in_range</b> <font face='Lucida Console'>(</font>
                <font color='#0000FF'><u>double</u></font> begin,
                <font color='#0000FF'><u>double</u></font> end
            <font face='Lucida Console'>)</font>;
            <font color='#009900'>/*!
                requires
                    - begin &lt;= end
                ensures
                    - if (begin &lt; end) then
                        - returns a random double number N where:  begin &lt;= N &lt; end.
                    - else
                        - returns begin
            !*/</font>

            <font color='#0000FF'><u>double</u></font> <b><a name='get_random_gaussian'></a>get_random_gaussian</b> <font face='Lucida Console'>(</font>
            <font face='Lucida Console'>)</font>;
            <font color='#009900'>/*!
                ensures
                    - returns a random number sampled from a Gaussian distribution 
                      with mean 0 and standard deviation 1. 
            !*/</font>

            <font color='#0000FF'><u>void</u></font> <b><a name='swap'></a>swap</b> <font face='Lucida Console'>(</font>
                rand<font color='#5555FF'>&amp;</font> item
            <font face='Lucida Console'>)</font>;
            <font color='#009900'>/*!
                ensures
                    - swaps *this and item
            !*/</font> 

    <b>}</b>;

    <font color='#0000FF'>inline</font> <font color='#0000FF'><u>void</u></font> <b><a name='swap'></a>swap</b> <font face='Lucida Console'>(</font>
        rand<font color='#5555FF'>&amp;</font> a, 
        rand<font color='#5555FF'>&amp;</font> b 
    <font face='Lucida Console'>)</font> <b>{</b> a.<font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>b<font face='Lucida Console'>)</font>; <b>}</b>   
    <font color='#009900'>/*!
        provides a global swap function
    !*/</font>

    <font color='#0000FF'><u>void</u></font> <b><a name='serialize'></a>serialize</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> rand<font color='#5555FF'>&amp;</font> item, 
        std::ostream<font color='#5555FF'>&amp;</font> out 
    <font face='Lucida Console'>)</font>;   
    <font color='#009900'>/*!
        provides serialization support 
    !*/</font>

    <font color='#0000FF'><u>void</u></font> <b><a name='deserialize'></a>deserialize</b> <font face='Lucida Console'>(</font>
        rand<font color='#5555FF'>&amp;</font> item, 
        std::istream<font color='#5555FF'>&amp;</font> in
    <font face='Lucida Console'>)</font>;   
    <font color='#009900'>/*!
        provides deserialization support 
    !*/</font>
<b>}</b>

<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_RAND_KERNEl_ABSTRACT_
</font>

</pre></body></html>